Skip to content

按类型获取公告 - GetAnnouncementsByType

函数简介

按公告类型获取公告列表。

返回数据格式:

json
{
  "Code": 1,
  "Message": "",
  "TotalCount": 1,
  "Items": [
    {
      "Guid": "a0b1c2d3",
      "Title": "公告标题",
      "Content": "公告正文",
      "AnnouncementType": 1,
      "AnnouncementTypeText": "系统公告",
      "Priority": 1,
      "PriorityText": "普通",
      "IsPopup": true,
      "IsTop": false,
      "SortOrder": 10,
      "PublishTime": "2026-04-20 08:00:00",
      "ExpireTime": "2026-05-20 08:00:00",
      "TargetUrl": "",
      "IsRead": false
    }
  ]
}
字段名类型说明
Code整数结果状态码,通常 1 表示成功,0 或其他值表示失败。
Message字符串提示信息或错误信息;失败时多为 错误码:中文描述(如 "2003:参数无效")。成功时可能为 success。完整对照见 客户端错误码说明
TotalCount整数总数量。
Items数组公告结果列表,每个元素为一个公告对象。

常见错误码(Message 字段)

Message含义
2003:参数无效参数无效
2004:用户不存在用户不存在
2005:软件不可用或未开通软件不可用或未开通

Items 元素字段说明:

字段名类型说明
Guid字符串公告唯一标识。
Title字符串公告标题。
Content字符串公告正文内容。
AnnouncementType整数公告类型编码。
AnnouncementTypeText字符串公告类型文本说明。
Priority整数优先级编码。
PriorityText字符串优先级文本说明。
IsPopup布尔是否弹窗展示。
IsTop布尔是否置顶。
SortOrder整数排序值,值越小越靠前。
PublishTime字符串公告发布时间。
ExpireTime字符串公告过期时间。
TargetUrl字符串公告关联跳转链接。
IsRead布尔当前用户是否已读。

接口名称

GetAnnouncementsByType

DLL调用

long GetAnnouncementsByType(string userCode, string softCode, string softVersion, string dealerCode, int announcementType);

参数说明

参数名类型说明
userCode字符串用户码。
softCode字符串软件码。
softVersion字符串软件版本。
dealerCode字符串经销商码。
announcementType整数公告类型。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
OlaAuthAnnouncementListReturn result = ola.GetAnnouncementsByType("userCode", "softCode", "1.0.0", "dealerCode", 0);
// result.Code == 1 表示成功
csharp
using OLAPlug;

var ola = new OLAPlugServer();
OlaAuthAnnouncementListReturn result = ola.GetAnnouncementsByType("userCode", "softCode", "1.0.0", "dealerCode", 0);
// result.Code == 1 表示成功
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
json_result = ola.GetAnnouncementsByType("userCode", "softCode", "1.0.0", "dealerCode", 0)
# Python SDK 返回 JSON 字符串,需自行解析
java
import com.olaplug.OLAPlugServer;
import com.olaplug.model.OlaAuthAnnouncementListReturn;

OLAPlugServer ola = new OLAPlugServer();
OlaAuthAnnouncementListReturn result = ola.GetAnnouncementsByType("userCode", "softCode", "1.0.0", "dealerCode", 0);
// result.Code == 1 表示成功
go
import "github.com/ola/olaplug/olaplug"

ola, _ := olaplug.NewOLAPlugServer("OLAPlug_x64.dll")
defer ola.ReleaseObj()
result := ola.GetAnnouncementsByType("userCode", "softCode", "1.0.0", "dealerCode", 0)
// result.Code == 1 表示成功
rust
use olaplug::OLAPlugServer;

let ola = OLAPlugServer::new("OLAPlug_x64.dll").unwrap();
let result = ola.get_announcements_by_type("userCode", "softCode", "1.0.0", "dealerCode", 0);
// result.code == 1 表示成功
cpp
var ola = com("OlaPlug.OlaSoft")
var result = ola.GetAnnouncementsByType("userCode", "softCode", "1.0.0", "dealerCode", 0)
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
Set result = ola.GetAnnouncementsByType("userCode", "softCode", "1.0.0", "dealerCode", 0)
text
.局部变量 ola, OLAPlug
.局部变量 result, OlaAuthAnnouncementListReturn
ola.创建 ()
result = ola.GetAnnouncementsByType(“userCode”, “softCode”, “1.0.0”, “dealerCode”, 0)
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var json = ola.GetAnnouncementsByType("userCode", "softCode", "1.0.0", "dealerCode", 0);
// Aardio SDK 返回 JSON 字符串,需自行解析
text
变量 ola <类型 = OLAPlugServer>
变量 result <类型 = OlaAuthAnnouncementListReturn>
ola = 新建 OLAPlugServer
result = ola.GetAnnouncementsByType("userCode", "softCode", "1.0.0", "dealerCode", 0)
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
OlaAuthAnnouncementListReturn result = ola.GetAnnouncementsByType("userCode", "softCode", "1.0.0", "dealerCode", 0);
// result.Code == 1 表示成功

原生 DLL 调用

cpp
long ptr = GetAnnouncementsByType(instance, "userCode", "softCode", "1.0.0", "dealerCode", 0);
if (ptr != 0) {
    char buffer[512] = {0};
    GetStringFromPtr(ptr, buffer, sizeof(buffer));
    FreeStringPtr(ptr);
}
csharp
using System.Runtime.InteropServices;
using System.Text;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringFromPtr(long ptr, StringBuilder lpString, int size);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int FreeStringPtr(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringSize(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long GetAnnouncementsByType(string userCode, string softCode, string softVersion, string dealerCode, int announcementType);

long ptr = GetAnnouncementsByType(instance, "userCode", "softCode", "1.0.0", "dealerCode", 0);
if (ptr != 0) {
    StringBuilder sb = new StringBuilder(GetStringSize(ptr) + 1);
    GetStringFromPtr(ptr, sb, sb.Capacity);
    FreeStringPtr(ptr);
    string result = sb.ToString();
}
python
from ctypes import CDLL, c_int, c_int64, create_string_buffer

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
ptr = ola.GetAnnouncementsByType(instance, "userCode", "softCode", "1.0.0", "dealerCode", 0)
if ptr:
    buf = create_string_buffer(512)
    ola.GetStringFromPtr(ptr, buf, 512)
    ola.FreeStringPtr(ptr)
    result = buf.value.decode("utf-8")

返回值

调用方式返回值说明
SDKOlaAuthAnnouncementListReturn结构化返回对象;Code == 1 表示成功
原生 DLL非 0成功,返回 JSON 字符串格式的结果。
原生 DLL0失败。

注意事项

项目说明
释放内存返回的字符串指针需要调用 FreeStringPtr 接口释放内存。
公告类型值请与服务端定义保持一致公告类型值请与服务端定义保持一致。